package com.nova.android.tvlauncher.ui.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import com.nova.android.tvlauncher.constants.ConstantsAtv
import sendLiveEventData

class NetworkChangeReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        val connectivityManager =
            context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
        val activeNetwork = connectivityManager.activeNetworkInfo
        val isConnected = activeNetwork?.isConnectedOrConnecting == true
        sendLiveEventData(ConstantsAtv.NET_CONNECT_CHANGE, isConnected)
    }
}
